package org.wx.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("/hello")
    String hello(){
        return "hello";
    }

    @GetMapping("/index")
    String index(){
        return "index";
    }

    @GetMapping("/info")
    String info(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        System.out.println(authentication.getName());
        System.out.println(authentication.getCredentials());

        authentication.getAuthorities().forEach(authoritie ->{
            System.out.println(authoritie.toString());
        });

        return "info";
    }

}
